package com.iqiyi.pps.epg.core.dao.ticket;

import com.iqiyi.pps.epg.api.model.web.ticket.TTicketData;
import com.iqiyi.pps.epg.core.dao.base.BaseDao;
import com.iqiyi.pps.epg.core.model.ticket.TicketData;
import com.iqiyi.pps.epg.core.utils.DateTimeUtil;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by karkarrotxu on 2017/8/29.
 */
@Component
public class TicketDataDao extends BaseDao<TicketData> {
    public TTicketData transToThrift(TicketData tempData) {
        TTicketData entity = new TTicketData();
        entity.setId(tempData.getId());
        entity.setDataType(tempData.getDataType());
        entity.setPriority(tempData.getPriority());
        entity.setStatus(tempData.getStatus());
        entity.setExecutor(tempData.getExecutor());
        entity.setReporter(tempData.getReporter());
        entity.setTitle(tempData.getTitle());
        entity.setDetail(tempData.getDetail());
        entity.setResourceId(tempData.getResourceId());
        entity.setAddTime(DateTimeUtil.transLongFormat(tempData.getAddTime().getTime()));
        entity.setDeadline( tempData.getDeadline());
        entity.setOaDocNo( tempData.getOaDocNo());
        entity.setOaDocEditorStatus( tempData.getOaDocEditorStatus());
        entity.setOaDocUrl( tempData.getOaDocUrl());
        return entity;
    }

    public List<TTicketData> transToTList(List<TicketData> dataList) {
        List<TTicketData> resultList = new ArrayList<>();
        TTicketData entity = null;
        for (TicketData tempData : dataList) {
            entity = transToThrift(tempData);
            resultList.add(entity);
        }
        return resultList;
    }
}
